<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除浮动影响</title>
    <style>
    ul{
        /* 当布局设置了宽度以及左右外边距为auto时，自动居中 */
        padding: 0px;
        width: 1200px;
        /* height: 200px; */
        border: 1px solid palevioletred;
        margin: 0px auto 20px;
    }
    ul li{
        list-style: none;
        width: 200px;
        height: 200px;
        background: pink;
        /* 设置文字水平居中 */
        text-align: center;
        /* 设置行高等于高度时，文字垂直居中 */
        line-height: 200px;
        /* 设置浮动 */
        float: left;
        margin: 0 20px;
    }
    /* 设置溢出隐藏 */
    .overflow{
        overflow: hidden;
    }
    /* 设置清除浮动 */
    .clear{
        clear: both;
    }
    .clearfix::before{
        content: "111";
        display: block;
    }
    .clearfix::after{
        content: "";
        display: block;
        clear: both;
    }
    </style>
</head>
<body>
    <h2>利用溢出影藏overflow: hidden;来消除浮动的影响</h2>
    <ul class="overflow">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
    <h2>在最后一个子元素后加上一个块级元素，设置clear:both;</h2>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <div class="clear"></div>
    </ul>
    <h2>使用伪元素after设置clear:both;</h2>
    <ul class="clearfix">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
</body>
</html>